<!--  Nguyen Huu Nhat -->
<?php 
@session_start();
include '../Security/CheckAdmin.php';
include '../DataBase/ConnectDB.php';
 include '../Home/DefineVar.php';
 mysql_select_db(MYSQL_DATABASE,$link);

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="../FileForInterface/popcalendar.js"></script> 
</head>
<body>
<!--会議室情報を入力する画面-->
<h1>会議室探索</h1>
<form action = 'SearchRoom.php' method='get'>
<table>
<tr><td>会議室名</td>
<td><input type='text' name='roomName'　 <?php echo "value ='".$_GET['roomName']."'"; ?>　></td>
</tr>

<tr><td>席数</td>
<td><input type='text' name='chairNumber'  <?php echo "value ='".$_GET['chairNumber']."'"; ?>></td>
</tr>

<tr><td>使用料</td>
<td><input type='text' name='useFee'  <?php echo "value ='".$_GET['useFee']."'"; ?> ></td>
</tr>

<tr><td>キャンセル料</td>
<td><input type='text' name='cancelFee'  <?php echo "value ='".$_GET['cancelFee']."'"; ?>></td>
</tr>

<tr><td>罰金</td>
<td><input type='text' name='fineFee'  <?php echo "value ='".$_GET['fineFee']."'"; ?>></td>
</tr>

<tr><td>予約手数料</td>
<td><input type='text' name='orderFee'  <?php echo "value ='".$_GET['orderFee']."'"; ?>></td>
</tr>
</table>
<input type='submit' value='探索' style="height:40px; width:100px;margin-left:140px;margin-top:30px;font-size:1.3em;">
</form>	
<?php 
////////////////////////////////////////////////////////////////////////

$roomName = mysql_real_escape_string($_GET['roomName']);
$chairNumber = mysql_real_escape_string($_GET['chairNumber']);
$useFee = mysql_real_escape_string($_GET['useFee']);
$cancelFee = mysql_real_escape_string($_GET['cancelFee']);
$fineFee =mysql_real_escape_string($_GET['fineFee']);
$orderFee =mysql_real_escape_string($_GET['orderFee']);

$query = "SELECT * FROM ".MYSQL_TABLE_ROOMINFOR." WHERE roomstatus <= 1 ";

if($roomName != ""){
$query .= "AND roomname like '%$roomName%' ";
}
if($chairNumber != ""){
$query .= "AND seatnumber = $chairNumber ";
}
if($useFee != ""){
$query .= "AND usingcost = $useFee ";
}
if($fineFee != ""){
$query .= "AND finefee = $fineFee ";
}
if($orderFee != ""){
$query .= "AND orderfee = $orderFee ";
}

//print("<br>".$query);
//print($query);
$result = mysql_query($query, $link);

if(mysql_num_rows($result)!=0){
	
print("<h1> 会議室情報</h1>");
print("<table border ='2' bordercolor = '0000FF' cellspacing ='1' style='font-size: 18px'><tbody align='center' size='5'><tr><td>会議室名</td><td>席数</td><td>使用料</td><td>予約手数料</td><td>キャンセル料</td><td>罰金</td></tr>");
//検索条件を表す。
while($row=mysql_fetch_array($result)){
print("<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]VND/30分</td><td>$row[5]VND/30分</td><td>$row[4]VND</td><td>$row[3]VND/30分</td><td><a href=UpdateRoom.php?roomId=$row[7]>更新</a></td></tr>");
}
print("</tbody></table>");
}
else{
	print("<br><h1>探索条件に応じての会議室はない</h1>");
}
mysql_close($link);
?>
</body>
</html>